package com.kh.rationaldrugreview.neo4j.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Property;

/**
 * 患者相关的关系定义
 * Patient-related relationship definitions
 */
public class PatientRelationships {
    
    /**
     * 适用于关系
     * SUITABLE_FOR relationship: Drug -> PatientProfile
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SuitableForRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("conditions")
        private String conditions; // 适用条件
        
        @Property("dosageAdjustment")
        private String dosageAdjustment; // 剂量调整
        
        @Property("monitoringRequired")
        private Boolean monitoringRequired; // 是否需要监测
        
        @Property("specialInstructions")
        private String specialInstructions; // 特殊说明
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 特定人群禁用关系
     * CONTRAINDICATED_FOR_PROFILE relationship: Drug -> PatientProfile
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ContraindicatedForProfileRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("reason")
        private String reason; // 禁用原因
        
        @Property("severity")
        private String severity; // 严重程度（绝对禁忌/相对禁忌）
        
        @Property("alternative")
        private String alternative; // 替代方案
        
        @Property("riskDescription")
        private String riskDescription; // 风险描述
        
        @Property("strength")
        private Integer strength; // 关系强度（通常为9-10）
    }
    
    /**
     * 需要调整关系
     * REQUIRES_ADJUSTMENT_FOR relationship: Drug -> PatientProfile
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RequiresAdjustmentForRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("adjustmentType")
        private String adjustmentType; // 调整类型（剂量/频率/疗程）
        
        @Property("adjustmentFactor")
        private Double adjustmentFactor; // 调整系数
        
        @Property("monitoringParameters")
        private String monitoringParameters; // 监测参数
        
        @Property("adjustmentFormula")
        private String adjustmentFormula; // 调整公式
        
        @Property("clinicalConsiderations")
        private String clinicalConsiderations; // 临床考虑
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 妊娠分级关系
     * HAS_PREGNANCY_CATEGORY relationship: Drug -> PregnancyCategory
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class HasPregnancyCategoryRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("evidenceQuality")
        private String evidenceQuality; // 证据质量（高/中/低）
        
        @Property("updateDate")
        private String updateDate; // 更新日期
        
        @Property("source")
        private String source; // 信息来源（FDA/药监局等）
        
        @Property("trimesterSpecific")
        private String trimesterSpecific; // 孕期特异性信息
        
        @Property("fetalRisk")
        private String fetalRisk; // 胎儿风险描述
        
        @Property("maternalBenefit")
        private String maternalBenefit; // 母体获益描述
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 年龄组适用关系
     * APPROPRIATE_FOR_AGE relationship: Drug -> AgeGroup
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AppropriateForAgeRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("dosageByWeight")
        private String dosageByWeight; // 按体重剂量（mg/kg）
        
        @Property("dosageByAge")
        private String dosageByAge; // 按年龄剂量
        
        @Property("maxDose")
        private String maxDose; // 最大剂量
        
        @Property("formulation")
        private String formulation; // 适合的剂型（糖浆/颗粒等）
        
        @Property("specialConsiderations")
        private String specialConsiderations; // 特殊考虑
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 器官功能要求关系
     * REQUIRES_ORGAN_FUNCTION relationship: Drug -> OrganFunction
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RequiresOrganFunctionRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("minimumFunction")
        private String minimumFunction; // 最低功能要求
        
        @Property("dosageAdjustment")
        private String dosageAdjustment; // 剂量调整方案
        
        @Property("monitoringFrequency")
        private String monitoringFrequency; // 监测频率
        
        @Property("contraindicationThreshold")
        private String contraindicationThreshold; // 禁忌阈值
        
        @Property("clinicalMarkers")
        private String clinicalMarkers; // 临床标志物
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 代谢型影响关系
     * AFFECTED_BY_METABOLIZER relationship: Drug -> MetabolizerType
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AffectedByMetabolizerRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("enzyme")
        private String enzyme; // 相关酶
        
        @Property("impact")
        private String impact; // 影响（增加/减少暴露量）
        
        @Property("dosageModification")
        private String dosageModification; // 剂量修改建议
        
        @Property("alternativeDrug")
        private String alternativeDrug; // 替代药物
        
        @Property("testingRecommended")
        private Boolean testingRecommended; // 是否推荐基因检测
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
    
    /**
     * 性别特异性关系
     * GENDER_SPECIFIC relationship: Drug -> Gender
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class GenderSpecificRelationship {
        @Id @GeneratedValue
        private Long id;
        
        @Property("gender")
        private String gender; // 性别（男/女）
        
        @Property("reason")
        private String reason; // 原因（激素影响/生理差异等）
        
        @Property("dosageDifference")
        private String dosageDifference; // 剂量差异
        
        @Property("efficacyDifference")
        private String efficacyDifference; // 疗效差异
        
        @Property("adverseReactionDifference")
        private String adverseReactionDifference; // 不良反应差异
        
        @Property("strength")
        private Integer strength; // 关系强度
    }
}